﻿#ifndef DAQ322_WRAPPER_H
#define DAQ322_WRAPPER_H

#include "libdaq/utils/wrapper_util.h"
#include <cstdint>

#ifdef __cplusplus
extern "C" {
#endif

// 设备生命周期管理
DLL_EXPORT uint32_t* CALL_FUNCTION DAQ322_New();
DLL_EXPORT void CALL_FUNCTION DAQ322_Delete(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_UseBackend(uint32_t* base_class, uint32_t* backend_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_InitializeDevice(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConnectedDevice(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_DisconnectedDevice(uint32_t* base_class);

// ADC配置函数
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCTrigger(uint32_t* base_class, int type, int mode, int channel, int level);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCSampleRate(uint32_t* base_class, int sample_rate);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCVoltage(uint32_t* base_class, int voltage);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCVoltage_Batch(uint32_t* base_class, const int* range_array, int array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCTriggerLength(uint32_t* base_class, uint32_t data_length);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigTriggerTimeout(uint32_t* base_class, uint32_t timeout);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCChannel(uint32_t* base_class, uint8_t channel);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCChannel_Batch(uint32_t* base_class, const bool* enable_array, int array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigACDC(uint32_t* base_class, uint8_t channel);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ConfigADCTriggerSource(uint32_t* base_class);

// 数据采集控制
DLL_EXPORT bool CALL_FUNCTION DAQ322_StartCollection(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_StopCollection(uint32_t* base_class);

// 数据读取函数
DLL_EXPORT bool CALL_FUNCTION DAQ322_TryReadData(uint32_t* base_class, uint8_t channel, float* read_buffer, uint32_t read_size, uint32_t timeout);
DLL_EXPORT bool CALL_FUNCTION DAQ322_TryReadData_Point(uint32_t* base_class, uint8_t channel, float* read_buffer);
DLL_EXPORT bool CALL_FUNCTION DAQ322_TryReadData_Batch(uint32_t* base_class, uint8_t channel, float* read_buffer, uint32_t read_size);

// 缓冲区管理
DLL_EXPORT bool CALL_FUNCTION DAQ322_ClearDataBuffer(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ClearDataBuffer_Channel(uint32_t* base_class, uint8_t channel);

// 服务器信息
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetServerInfo(uint32_t* base_class, char* ip_buffer, int ip_buffer_size, uint32_t* port);

// 设备信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ322_ProductTestGetSN(uint32_t* base_class, char* sn_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetSN(uint32_t* base_class, char* sn_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_SystemOpGetDeviceName(uint32_t* base_class, char* name_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetDeviceName(uint32_t* base_class, char* name_buffer, int buffer_size);

// 基本信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ322_BasicInfoGetDeviceType(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ322_BasicInfoGetHardwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_BasicInfoGetBootLoaderVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_BasicInfoGetSoftwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);

// 版本信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetDeviceType(uint32_t* base_class, char* type_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetHardwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetBootLoaderVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetSoftwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);

// ADC参数获取
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetADCLegalSampleRate(uint32_t* base_class, uint32_t* rate_array, int* array_size);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ322_GetCurrentSampleRate(uint32_t* base_class);
DLL_EXPORT uint8_t CALL_FUNCTION DAQ322_GetADCLegalChannelSize(uint32_t* base_class);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ322_GetADCBufferDataSize(uint32_t* base_class, int channel);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ322_GetADCBufferDataMaxSize(uint32_t* base_class);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ322_GetADCLegalLengthMin(uint32_t* base_class);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ322_GetADCLegalLengthMax(uint32_t* base_class);
DLL_EXPORT uint8_t CALL_FUNCTION DAQ322_GetChannelEnableState(uint32_t* base_class);

// 参数验证函数
DLL_EXPORT bool CALL_FUNCTION DAQ322_ADCSampleRateIsLegal(uint32_t* base_class, uint32_t sample_rate);
DLL_EXPORT bool CALL_FUNCTION DAQ322_ADCRangeIsLegal(uint32_t* base_class, int range);

// 配置信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetADCLegalChannel(uint32_t* base_class, uint32_t* channel_array, int* array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetADCLegalVoltage(uint32_t* base_class, uint32_t* voltage_array, int* array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetCurrentTriggerType(uint32_t* base_class, uint32_t* trigger_type);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetCurrentTriggerMode(uint32_t* base_class, uint32_t* trigger_mode);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetChannelEnableList(uint32_t* base_class, bool* enable_array, int* array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetADCCurrentVoltage(uint32_t* base_class, uint32_t* voltage_array, int* array_size);

// GPIO接口
DLL_EXPORT bool CALL_FUNCTION DAQ322_SetGPI(uint32_t* base_class, const uint8_t* gpio_state, int array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetGPI(uint32_t* base_class, uint8_t* gpio_state, int* gpio_state_size, bool* gpio_trigger_output, int* trigger_output_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_EnableGPITriggerOutput(uint32_t* base_class, const bool* gpio_trigger_output, int array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ322_GetGPIOState(uint32_t* base_class, uint8_t* gpio_state, int* array_size);

#ifdef __cplusplus
}
#endif

#endif // DAQ322_WRAPPER_H
